var navColumnItem = document.getElementsByClassName("navColumnItem");
var contentArea = document.getElementsByClassName("contentArea");
var switchItem = document.getElementsByClassName("switchItem");
var switchPage = document.getElementsByClassName("switchPage");
var addDepartment = document.getElementById("addDepartment");
var departmentManage = document.getElementById('departmentManage');
var crateDepartment = document.getElementById('crateDepartment');
var addEmployee = document.getElementById("addEmployee");
var employeeManage = document.getElementById('employeeManage');
var appendEmployee = document.getElementById('appendEmployee');
var checkReport = document.getElementById("checkReport");
var workReport = document.getElementById('workReport');

// 返回数组下标函数
function getArrayIndex(arr, obj) {
    var i = arr.length;
    while (i--) {
        if (arr[i] === obj) {
            return i;
        }
    }
    return -1;
}
// tab切换函数
function tabClick(tabOption,tabPage) {
	for (var index = 0; index < tabOption.length; index++) {
		tabOption[index].onclick = function() {
			if(getArrayIndex(tabOption, this) == 1){			
				crateDepartment.style.display="none";
				departmentManage.style.display="block";
			}
			if(getArrayIndex(tabOption, this) == 2){			
				appendEmployee.style.display="none";
				employeeManage.style.display="block";
			}
			if (this.classList.toString().search(/actived/) == -1) {
				for (var j = 0; j < tabOption.length; j++) {
					if (tabOption[j].classList.toString().search(/actived/) != -1) {
						tabOption[j].classList.remove("actived");
					}
				}
				this.classList.add("actived");
				for (var j = 0; j < tabPage.length; j++) {
					if (tabPage[j].classList.toString().search(/actived/) != -1) {
						tabPage[j].classList.remove("actived");
					}
				}
				tabPage[getArrayIndex(tabOption, this)].classList.add("actived");			
			}
		}
	}
}
// 页面隐藏函数
function hideShowUp(button,contentHide,contentShowUp){
	button.onclick =function(){
		contentHide.style.display="none";
		contentShowUp.style.display="block";
	}
}

hideShowUp(addDepartment,departmentManage,crateDepartment);
hideShowUp(addEmployee,employeeManage,appendEmployee);
hideShowUp(checkReport,employeeManage,workReport);

tabClick(navColumnItem,contentArea);
tabClick(switchItem,switchPage);
